package org.devocean.groupbuying.domain;

import java.io.Serializable;


import java.util.HashSet;
import java.util.Date;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

@SuppressWarnings("serial")
@Entity
public class Voucher implements Serializable {

	@Id
	@GeneratedValue
	private Integer voucherID;
	private Date expireDate;
	private String voucherLocation;


	@OneToMany(cascade = CascadeType.ALL,mappedBy = "voucher", fetch = FetchType.LAZY)
	private Set<SerialKey> serialKeys = new HashSet<SerialKey>();


	@OneToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "discountID", referencedColumnName = "discountID", nullable = true)
	private Discount discount;

	public Voucher() {

	}

	public Integer getVoucherID() {
		return voucherID;
	}

	public void setVoucherID(Integer voucherID) {
		this.voucherID = voucherID;
	}

	public Date getExpireDate() {
		return expireDate;
	}

	public void setExpireDate(Date expireDate) {
		this.expireDate = expireDate;
	}

	public String getVoucherLocation() {
		return voucherLocation;
	}

	public void setVoucherLocation(String voucherLocation) {
		this.voucherLocation = voucherLocation;
	}

	public Set<SerialKey> getSerialKeys() {
		return serialKeys;
	}

	public void setSerialKeys(Set<SerialKey> serialKeys) {
		this.serialKeys = serialKeys;
	}

	public Discount getDiscount() {
		return discount;
	}

	public void setDiscount(Discount discount) {
		this.discount = discount;
	}

	@Override
	public String toString() {
		return "Voucher [voucherID=" + voucherID + ", expireDate=" + expireDate
				+ ", voucherLocation=" + voucherLocation + ", serialKeys="
				+ serialKeys;
	}

}
